/*
**********************************************************************************
    OpenSURF642 : An TI DM642 implementation of OpenSURF.
    Copyright (C) 2011  Hai Yu

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
	This implementation is based on The original OpenSURF library created
	by Christopher Evans.The original work can be found at
		http://www.chrisevansdev.com/computer-vision-opensurf.html
	
    contact: yuhaihai12345@gmail.com	
**********************************************************************************
*/

#ifndef _RESPONSE_LAYER_
#define _RESPONSE_LAYER_

#include "opensurf642util.h"

//typedef  Int32 ResponseDataType;
typedef  Int16 ResponseDataType;
/***********    Definition of structures  ***************************/
typedef struct
{
	ResponseDataType * responses;
	Uint8  * laplacians;
	
	Uint8  step;
	Uint16  filter;

	Uint16 height;
	Uint16 width;

}ResponseLayer;


/***********    Declaration of Interfaces  ***************************/

ResponseLayer * CreateResponseLayer(Uint16 width, Uint16 Height, Uint16 step, Uint16 filter);

void DeleteResponseLayer(ResponseLayer * rl);

inline Uint8 GetLaplacian(ResponseLayer * self, Uint16 row, Uint16 col)
{
	return self->laplacians[row * self->width + col];
}

inline Uint8 GetLaplacian2(ResponseLayer * self, Uint16 row, Uint16 col, ResponseLayer * src)
{
	Uint16 scale = self->width / src->width;
	return self->laplacians[(row * self->width + col) * scale];
}

inline ResponseDataType GetResponse(ResponseLayer * self, Uint16 row, Uint16 col)
{
	return self->responses[row * self->width + col];
}

inline ResponseDataType GetResponse2(ResponseLayer * self, Uint16 row, Uint16 col, ResponseLayer * src)
{
	Uint16 scale = self->width / src->width;
	return self->responses[(row * self->width + col) * scale];
}
#endif



